var arrayControls = [];

function toggleCheckAll(readId, replyId, voteId, ctopicId, cpollId, cstickyId, cannounceId, cfaqId, eownId, downId, modId)
{
    read = document.getElementById(readId);
    reply = document.getElementById(replyId);
    vote = document.getElementById(voteId);
    ctopic = document.getElementById(ctopicId);
    cpoll = document.getElementById(cpollId);
    csticky = document.getElementById(cstickyId);
    cannounce = document.getElementById(cannounceId);
    cfaq = document.getElementById(cfaqId);
    eown = document.getElementById(eownId);
    down = document.getElementById(downId);
    mod = document.getElementById(modId);

    b = arrayControls[readId];
    arrayControls[readId] = !b;

    read.checked = !b;
    reply.checked = !b;
    vote.checked = !b;
    ctopic.checked = !b;
    cpoll.checked = !b;
    csticky.checked = !b;
    cannounce.checked = !b;
    cfaq.checked = !b;
    eown.checked = !b;
    down.checked = !b;
    mod.checked = !b;
}

function setChecked(isChecked, toIds, fromObj)
{
   if (fromObj.checked)
    {
        if (toIds.indexOf(";") > 0)
        {
            var toId = "";
            var checkbox;
            while (toIds.indexOf(";") > 0)
            {
                toId = toIds.substring(0, toIds.indexOf(";"));
                if (toId != fromObj.id)
                {
                    highlightCheckbox(document.getElementById(toId), isChecked);
                }

                toIds = toIds.substring(toIds.indexOf(";") + 1, toIds.length);
            }
            highlightCheckbox(document.getElementById(toIds), isChecked);
        }
        else
        {
            toObj = document.getElementById(toIds);
            if (toObj.id != fromObj.id)
            {
                highlightCheckbox(toObj, isChecked);
            }
        }
    }
}

function highlightCheckbox(checkbox, endWithCheck)
{
    if (!checkbox.checked && !checkbox.isChecking)
    {
        checkbox.checked = endWithCheck;
        checkbox.isChecking = true;
        checkbox.numberOfBlinks = 0;
        var highlightInterval = setInterval(
            function()
            {
                if (checkbox.numberOfBlinks < 4)
                {
                    checkbox.checked = !checkbox.checked;
                }
                else
                {
                    clearInterval(highlightInterval);
                    checkbox.checked = endWithCheck;
                    checkbox.isChecking = false;
                }
                checkbox.numberOfBlinks++;
            },
            200
        );
    }
}